<template>
	<view class="container">
		<view class="top-view">
			<children-base-top-view :name="children.name" :gender="children.gender" :imgUrl="children.imgUrl"
				:month="children.month"
				 :birthday="children.birthday"/>
		</view>
		<view v-for="(item, index) in list" :key="index" class="evlItem">
			<view class="evaluate-item" @click="itemClick(item)">
				<view class="title">月报报告</view>
				<view class="time">{{$u.timeFormat(item.created, 'yyyy年mm月dd日')}}</view>
				<view class="evaluate-more">
					<view class="month">
						月报月龄{{item.childrenMonth}}月
					</view>
					<view class="teacher">
						记录人:{{item.createdName}}
					</view>
				</view>
			</view>
		</view>
		<u-empty class="noContent" v-if="emptyShow" text="暂时没有宝宝的测评哦～"  mode="list"></u-empty>
		<u-loadmore v-if="!emptyShow" :status="status" />
		<fab @fabClick="fabClick"/>
	</view>
</template>

<script>
	import pageMixin from '@/mixins/page.js'
	import { formatDateByTimestamp, wrapMonthByBirthday } from '@/utils/utils.js'
	import ChildrenBaseTopView from '@/components/children-base-top-view.vue'
	import { getMonthlyList } from '@/api/monthly.js'
	import {
		mapState,
	} from 'vuex';
	import Fab from '@/components/fab.vue'
	export default {
		mixins: [pageMixin],
		components: {
			ChildrenBaseTopView,
			Fab
		},
		computed: {
			...mapState({
				appTheme: state => state.app.appTheme
			})
		},
		data() {
			return {		
				children: {},
				list: []
			}
		},
		onLoad(options) {
			console.log(options);
			this.children = options;
		},
		onShow() {
			this.page = -1;
			this.getList(this.page);
		},
		methods: {
			fabClick() {
				this.$u.route({
					url: '/pages_sub/monthly/monthly-report-page',
					params: {
						type: 'create',
						childrenId: this.children.id,
						month: this.formatMonth(),
					}
				})
			},

			getList(index) {
				const params = {
					pageNum: index + 1,
					pageSize: 20,
					childrenId: this.children.id
				}
				getMonthlyList(params).then(res => {
					this.setData(res);
				})
			},
			
			itemClick(item) {
				this.$u.route({
					url: '/pages_sub/monthly/monthly-report-page',
					params: {
						type: 'preview-tch',
						childrenId: this.children.id,
						month: item.childrenMonth,
					}
				})
			},
			
			formatMonth() {
				return wrapMonthByBirthday(parseInt(this.children.birthday));
			}
		}
	}
</script>

<style lang="scss">
	page{
		height: 100%;
		background-color: $app-page-bg-color;
	}
	.container{
		margin-top: 20rpx;
		display: flex;
		flex-direction: column;

		.top-view{
			display: flex;
			justify-content: center;
			align-items: center;
		}
		
		.body{

		}
	}
	
	.evlItem {
		background-color: #FFFFFF;
		border-radius: 20rpx;
		padding-left: 30rpx;
		padding-right: 30rpx;
		padding-top: 20rpx;
		padding-bottom: 20rpx;
		margin-top: 20rpx;
		margin-bottom: 20rpx;
		margin-left: 30rpx;
		margin-right: 30rpx;
	}
	
	.evaluate-item{
		display: flex;
		flex-direction: column;
		color: $app-font-color;
		.title{
			font-size: 30rpx;
			font-weight: bold;
		}
		
		.time{
			font-size: 26rpx;
			margin-top: 10rpx;
		}
		
		.evaluate-more{
			display: flex;
			flex-direction: row;
			margin-top: 10rpx;
			font-size: 22rpx;
			.month{
				
			}
			
			.teacher{
				margin-left: 20rpx;
			}
		}
	}
</style>
